angular.module('starter')
.controller("remarksCtrl", function ($scope,$ionicHistory, $state, $stateParams, $rootScope) {

    //获取参数
    var DoctorParma = $stateParams.DoctorParma || {};
    var ptype = $stateParams.type || 0;
     

	//有否过敏史
    $scope.allergyList = [];
    $scope.remarks = [];
    $scope.allergyBol = true;
	$scope.switchCheck = function(){
		var thisSwitch = $(".remarks .switch");
		if(thisSwitch.is(':checked')){
			//console.log("开")
			$scope.allergyBol = true;
		}else{
			//console.log("关")
			$scope.allergyBol = false;
		}
	}
	
	//选择过敏源
	$scope.allergy_type = ["鸡蛋","花生","阿莫西林","扑尔敏","苯海拉明"];
	$scope.onIndexBol = false;
	$scope.typeSelect = function(item){
		return this.onIndexbol = !this.onIndexbol;
	}

	$scope.subRemarks = function ()
	{
	    $scope.remarks.allergyList = [];
	    if (!$scope.allergyBol) {
	        $scope.remarks.allergyName = "";
	        $scope.remarks.allergyList = [];
	    }
	    else {
	       $(".allergy_type>i.on").each(function(){
	           $scope.remarks.allergyList.push($(this).text());
	        });
	    }
	    if (ptype == 1) {
	        $ionicHistory.goBack();
	    } else {
	        $state.go('placeOrder', {
	            doctorParma: DoctorParma,
	            regFee: DoctorParma.regFee,
	            regDate: DoctorParma.regDate,
	            scheduleType: DoctorParma.scheduleType,
	            regTime: DoctorParma.regTime,
	            tempData: $scope.remarks
	        });
	    }
	    return;
	}
})
